Initial work on Ocrypt integration#1569
Initial work on Ocrypt integration#1569waywardgeek wants to merge 14 commits intoveracrypt:masterfrom
Conversation
- Add OCRYPT as PRF algorithm veracrypt#7 in Common/Crypto.h - Add Pkcs5HmacOcrypt class to Volume/Pkcs5Kdf.h/cpp - Create simple OcryptWrapper C interface for OpenADP SDK - Add derive_key_ocrypt implementation using VeraCrypt's SHA-256 functions - Update build system to compile with C++17 and OpenADP dependencies - Successfully build VeraCrypt with Ocrypt integration This enables nation-state resistant password protection using OpenADP's distributed threshold cryptography as a drop-in replacement for traditional password hashing functions like PBKDF2, bcrypt, and Argon2.
- Add Argon2 PRF providing 1000-10000x improved brute-force resistance over PBKDF2 - Add Ocrypt PRF foundation for OpenADP distributed threshold cryptography - Extend command line interface with --prf parameter for PRF algorithm selection - Add Pkcs5Argon2 and Pkcs5Ocrypt classes following existing VeraCrypt patterns - Integrate PRF algorithms into volume creation and mounting workflows - Maintain full backward compatibility with existing hash algorithms - Support for both interactive and non-interactive volume operations This implementation enables users to create containers with significantly enhanced security characteristics while maintaining VeraCrypt's existing architecture and user experience.
This commit implements a comprehensive integration of OpenADP's Ocrypt distributed threshold cryptography into VeraCrypt, providing nation-state resistant password protection as a drop-in replacement for traditional KDFs. Key Features: - Add OCRYPT as PRF algorithm veracrypt#7 alongside PBKDF2, bcrypt, Argon2 - Dual metadata storage: primary in VeraCrypt header + fallback .metadata.json - Automatic secret recovery using OpenADP distributed protocol (3-of-4 threshold) - Complete command-line support via --prf parameter - Thread-safe C/C++ wrapper bridging VeraCrypt to OpenADP SDK - Quantum-resistant security with perfect forward secrecy This enables users to create VeraCrypt volumes with exponentially enhanced security against nation-state attacks while maintaining full compatibility with existing workflows.
…neration - Fixed critical security issue where Ocrypt long-term secrets were generated using weak entropy from clock() and time() functions - Now uses /dev/urandom for cryptographically secure random number generation on Linux systems - Falls back to password-based key derivation if /dev/urandom is unavailable - Maintains Windows compatibility with VeraCrypt's RandgetBytes function - Each volume now gets a unique 32-byte random secret instead of predictable time-based values - Verified working: volume creation, mounting, and recovery all successful with secure random generation
- src/Common/Pkcs5.h: Add function declarations for ocrypt_reset_secret_cache() and ocrypt_single_recovery() - src/Volume/Volume.cpp: Add file handle setup for Ocrypt metadata access during volume opening - src/Core/VolumeCreator.cpp: Implement rollback-safe volume creation for Ocrypt volumes - Skip backup header creation during initial volume creation - Only write primary header and metadata initially - Backup header will be created during first recovery for atomic rollback safety These changes complete the Ocrypt integration with: - Secure random number generation (/dev/urandom) - Single-recovery architecture with version byte system - Atomic metadata updates with rollback safety - Proper file handle management for metadata access
- Exclude temporary test files, debug logs, and build artifacts - Keep repository clean by ignoring object files, dependencies, and test volumes
- Document current implementation status and architecture - Explain design decisions and trade-offs (plausible deniability vs security) - Detail security improvements (secure random generation, single-recovery) - Propose future 'Ocrypt Mode' approach with magic string detection - Cover compatibility with hidden volumes and system encryption - Provide development guidelines and contributing information - Include threat model analysis and appropriate use cases This README serves as the definitive guide for understanding our Ocrypt integration approach and future architectural plans.
- Updated Completed Features: Now uses OpenSSL RAND_bytes for cross-platform portability - Updated Security Features: All platforms use OpenSSL, no platform-specific dependencies - Updated Security Improvements: Latest fix uses OpenSSL instead of /dev/urandom - Added API documentation: ocrypt_random_bytes() wrapper function - Improved portability: No file access requirements or platform-specific code needed This completes the documentation for our secure, portable random generation architecture.
…entation - Updated volume layout to use magic string at byte 512 for instant Ocrypt detection - Moved version byte to offset 528, metadata to 529 (EVEN) and 16913 (ODD) - Added comprehensive TODO section for implementation requirements - Documented OpenSSL dependency challenge and potential solutions - Magic string design enables air-gap compatibility for traditional volumes - All offset references updated to match new layout
…tion - Add magic string 'OCRYPT1.0' at byte 512 for instant detection - Update offset constants: magic at 512, version at 528, metadata at 529/16913 - Add detect_ocrypt_magic_string() and write_ocrypt_magic_string() functions - Modify VolumeCreator to write magic string during Ocrypt volume creation - Add magic string detection in derive_key_ocrypt() to prevent air-gap issues - Magic string enables instant PRF selection without expensive crypto operations - Cross-platform implementation for Windows and Unix systems - All tests show correct magic string and version byte placement
- Phase 1 implementation completed successfully - Magic string detection fully functional - Cross-platform support verified - Air-gap compatibility issue resolved - Update implementation plan status
…ve usage examples - Fixed chicken-and-egg problem: Magic string detection now works correctly during volume creation - Modified derive_key_ocrypt() to continue with registration when no magic string found (new volume) - Added volume path setting in CoreUnix::MountVolume before OpenVolume call - Added comprehensive usage examples to README.md including: * Creating Ocrypt volumes with various options * Mounting and unmounting volumes * Listing mounted volumes * Volume information and troubleshooting * Advanced examples with keyfiles and different encryption algorithms Magic string detection is now fully functional for both creation and mounting workflows.
|
@idrassi; Have you seen this @waywardgeek PR? |
|
Thank you for putting this together and sorry for the delayed feedback. The project had been stalled because of various issues and I am only now resuming activities. After reviewing the PR and Ocrypt/OpenADP, I have several reservations about integrating this approach into VeraCrypt core. As a result, I do not think this PoC can be merged into VeraCrypt in its current form. As you noted, several aspects depart from VeraCrypt's philosophy and threat model, in particular the loss of plausible deniability and the addition of network access. After discussions with others, I do not think integrating such a feature directly into VeraCrypt core would be acceptable, even if it were not enabled by default. Separately, I am considering a narrower extension mechanism for VeraCrypt: user-selected virtual keyfile providers, similar in spirit to the existing EMV/security-token keyfile support. In that model, VeraCrypt would keep the standard volume format, header KDFs, XTS mode, master-key handling and header validation unchanged. A provider would not be auto-detected. The user would explicitly select it, VeraCrypt would render a limited declarative input form supplied by the provider and the provider would return virtual keyfile bytes that VeraCrypt mixes through the existing keyfile path. This could be a cleaner place for mechanisms such as OpenADP. OpenADP could be installed as a third-party extension by interested users and would act as an explicitly selected online virtual-keyfile provider rather than as a VeraCrypt PRF or a new header format. Any required OpenADP metadata would remain outside the VeraCrypt volume unless the user knowingly accepts the loss of plausible deniability. This is a separate design direction and not something this PR can resolve, but feedback on such a virtual-keyfile-provider model would be welcome. I will keep this PR open for now for discussion, although I do not intend to merge the current PoC. |
I'll need feedback on this PR to get it to the point that it is acceptable to the VeraCrypt authors. This version works in --text mode on Linux when creating and mounting volumes encrypted via Ocrypt. OpenSSL dependency. VeraCrtypt is missing bignum, AES-GCM, HKDF, and elliptic curve support for ed25519. How should I resolve this? E.g. is libnacl acceptably lightweight?
Ocrypt requires network access, making non-compatible with full-disk encryption, and it also has clear metadata I currently store in the header after address 512, defeating plausible deniability. Ocrypt must remember the URLs used to register its secret, so I see no way around this limitation.
The code is currently sloppy. However, it works and is a nice PoC. How should we proceed?